<?php
include_once("config.php");
if (isset($_SESSION['adminName'])){
	$isAdmin=true;
}else{
	$isAdmin=false;
}
if (isset($_POST['adminName']) && isset($_POST['adminPassword'])){
	$adminName=mysql_real_escape_string(stripcslashes($_POST['adminName']));
	$adminPassword=mysql_real_escape_string(stripcslashes($_POST['adminPassword']));
	$isValidInput=true;
}else{
	$isValidInput=false;
}
if ($isValidInput){
	$queryString="SELECT * FROM admin WHERE admin='$adminName' AND password='$adminPassword'";
	$result=mysql_query($queryString);
	$row=mysql_num_rows($result);
	if ($row==1){
		$isAdmin=true;
		$_SESSION['adminName']=$adminName;
	}
}
?>

<!DOCTYPE html>
<html>
<head>
	<title>Check | Admin</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
	<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
	<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
</head>
<body>
<?php
if (!$isAdmin){
?>
	<div class="jumbotron">
		<div class="container">
	  	Make sure you have the correct admin name and password. 
	  	<a href="adminLogin.php">Login</a>
		</div>
  </div>
<?php
}else{
  header("location: adminIndex.php");
}
?>
</body>
</html>
